package com.method.HomeWork;
/*
已知一个数组 arr = {19, 28, 37, 46, 50};
用程序实现把数组中的元素值反转(在原数组中操作，不能定义第二个数组)，
反转后的数组 arr = {50, 46, 37, 28, 19};
并在控制台输出反转后的数组元素。
 */
public class HomeWork15 {
    public static void main(String[] args) {
        int[]arr={19, 28, 37, 46, 50};
        int left =0;
        fanzhuan(arr, left);

    }

    public static void fanzhuan(int[] arr, int left) {
        int right =arr.length-1;
        int temp =arr[right];
        arr[right]=arr[left];
        arr[left] = temp;
        System.out.print("[");
        for (int x = 0; x < arr.length; x++) {
            if (x == arr.length - 1) {
                System.out.print(arr[x]);
            } else {
                System.out.print(arr[x] + ", ");
            }
        }
        System.out.println("]");
    }

}
